<?php
require('system-config.php');
require_once(PRIVATEROOT . 'wp-includes/registration-functions.php');
//$optiondomain = 'blog';

validateToken($_POST['token'], 'createusers.php');

$filename = $_FILES['newuserlist']['tmp_name'];
$fd = fopen ($filename, "r");
$contents = fread ($fd, filesize($filename));
fclose ($fd);

$accounts = explode(';', $contents);

foreach($accounts as $key => $value)
	$accounts[$key] = explode(',', $value);

foreach($accounts as $account){
	$wp_object_cache->cache=array();//clearing cache. flush() only takes care of cache files
	$password = substr( md5( uniqid( microtime() ) ), 0, 7);
	$user_id = wp_create_user( $account[0], $password, $account[1] );
	if ('yes' == $_POST['create_blog'])
		$blog_id = lyceum_create_blog( $user_id, $account[0] );
	wp_new_user_notification($user_id, $password);
}
header("Location: settings.php");

?>